package appinventor.ai_Ryan489.BBYM;

import android.app.TabActivity;
import android.content.Intent;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MainActivity extends TabActivity {
    /** Called when the activity is first created. */
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab);
        
        /* TabHost will have Tabs */
        TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
        
        /* TabSpec used to create a new tab. 
         * By using TabSpec only we can able to setContent to the tab.
         * By using TabSpec setIndicator() we can set name to tab. */
        
        /* tid1 is firstTabSpec Id. Its used to access outside. */
        TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
        TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
        TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
        
        /* TabSpec setIndicator() is used to set name for the tab. */
        /* TabSpec setContent() is used to set content for a particular tab. */
        firstTabSpec.setIndicator("Home").setContent(new Intent(this,HomeTab.class));
        secondTabSpec.setIndicator("Coverage Maps").setContent(new Intent(this,SecondTab.class));
        thirdTabSpec.setIndicator("Plans").setContent(new Intent(this,PlansTab.class));
        
        
        /* Add tabSpec to the TabHost to display. */
        tabHost.addTab(firstTabSpec);
        tabHost.addTab(secondTabSpec);
        tabHost.addTab(thirdTabSpec);
        
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }
    
    public void about(){
    	Intent i = new Intent(MainActivity.this, AboutMenu.class);
        startActivity(i);
    }
    public void changelog()
    {
    	Intent changelog = new Intent(MainActivity.this, Changelog.class);
    	startActivity(changelog);
    	
    }
    public void paymentCalc(){
    	Intent paymentcalc = new Intent(MainActivity.this, paymentCalc.class);
    	startActivity(paymentcalc);
    }
    
    public void buyback()
    {
    	Intent buybackgo = new Intent(MainActivity.this, buyBackulator.class);
    	startActivity(buybackgo);
    }
    
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
        case R.id.changelog:
        	changelog();
        	return true;
        	
        case R.id.paymentcalc:
        	paymentCalc();
        	return true;
        	
        case R.id.about:
            about();
            return true;
            
      //  case R.id.buyback:
        //	buyback();
        //	return true;
        	
        
        default:
            return super.onOptionsItemSelected(item);
        }
    }
}
